<!--
 * @Author: 高瑞寒 15932717091@163.com
 * @Date: 2022-04-25 21:35:52
 * @LastEditTime: 2022-04-27 11:34:09
 * @LastEditors: 高瑞寒 15932717091@163.com
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title></title>
</head>

<body>
  <div id="test"></div>
  <script type="text/javascript" src="../js/新/react.development.js"></script>
  <script type="text/javascript" src="../js/新/react-dom.development.js"></script>
  <script type="text/javascript" src="../js/新/babel.min.js">
  </script>
  <script src="../js/新/prop-types.js"></script>
  <script type="text/babel">
    class Life extends React.Component {
      constructor(props) {
        super(props)
        this.state = { count: 0 }
        console.log('construction');
      }
      add = () => {
        this.setState({ count: this.state.count + 1 })
      }
      static getDerivedStateFromProps(props, state) {
        console.log('getDerivedStateFromProps', props, state);
        return null
      }
      getSnapshotBeforeUpdate(preProps, preState) {
        console.log('getSnapshotBeforeUpdate', preProps, preState);
        return '快照值'
      }
      componentDidUpdate(preProps, preState,snapshotValue){
        console.log('componentDidUpdate', preProps, preState, snapshotValue);
      }
      render() {
        console.log('render');
        return (
          <div>
            <div>{this.state.count}</div>
            <button onClick={this.add}>+1</button></div>
        )
      }
    }
    ReactDOM.render(<div><Life  /></div>, document.querySelector('#test'))
  </script>
</body>

</html>